define( [
  'imgUploader',
  'bigwe_utils'
], function( iu, bu ) {
  var returnParam = {
    // 通过中间模块来解决图片上传模块传入匿名函数无法修改的问题
    imgOnSave: function() {},
    htmlBuild: {
      getVideoHtml: function( videoUrl ) {

        var html = '';
        html += '<div class="video_content">';
        html += '<p class="title gray">' + ( videoUrl.video_title || '无法获取标题' ) + '</p>';
        html += '<div class="video_wrap">';
        html += '<span class="glyphicon glyphicon-play-circle"></span>';
        html += '<video src="' + videoUrl.value + '"></video>';
        html += '</div>';
        if ( videoUrl.video_summary ) {
          html += '<p class="desc gray">' + ( videoUrl.video_summary ) + '</p>';
        }
        html += '</div>';

        return html;

      },
      getImgHtml: function( imgurl ) {

        var html = '';

        html += '<a class="content_img" href="' + imgurl + '" target="_blank">';
        html += '<img class="icon" src="' + bu.wechartImgCheck( imgurl ) + '">';
        html += '</a>';

        return html;
      },
      getGraphHtml: function( graphArray ) {

        var html = '';
        if ( !graphArray.length ) return html;
        html += '<div class="HeC">';
        html += '<div class="outer_content">';
        html += '<div class="HeC_1">';

        if ( graphArray.length == 1 ) {
          html += '<a class="title" target="_blank" href="' + graphArray[ 0 ].content_url + '">' + ( graphArray[ 0 ].title || '' ) + '</a>';
        }

        html += '<div class="HeC_1_inter">';
        html += '<a target="_blank" href="' + graphArray[ 0 ].content_url + '" class="cover" style="background-image: url(' + bu.wechartImgCheck( graphArray[ 0 ].cover_url ) + ');"></a>';
        if ( graphArray.length > 1 ) {
          html += '<a target="_blank" class="graph_gray" href="' + graphArray[ 0 ].content_url + '">' + graphArray[ 0 ].title + '</a>';
        }
        html += '</div>';

        if ( graphArray.length == 1 ) {
          html += '<div class="desc">' + ( graphArray[ 0 ].digest || '' ) + '</div>';
        }

        html += '</div>';
        html += '<div class="content">';
        html += '<table>';
        html += '<tbody>';

        for (var i in graphArray ) {
          if ( i != '0' ) {
            html += '<tr>';
            html += '<td>';
            html += '<a target="_blank" href="' + graphArray[ i ].content_url + '">' + graphArray[ i ].title + '</a>';
            html += '</td>';
            html += '<td>';
            html += '<div class="cover_right" style="background-image: url(' + bu.wechartImgCheck( graphArray[ i ].cover_url ) + ');"></div>';
            html += '</td>';
            html += '</tr>';
          }
        }

        html += '</tbody>';
        html += '</table>';
        html += '</div>';
        html += '</div>';
        html += '</div>';

        return html;

      },
      mpnewsData: function( data, gourpId ) {
        return {
          'article_group': gourpId,
          'content_url': data.cd ? '/_article?p=' + data.cd : '',
          'cover_url': data.cover,
          'digest': data.summary,
          'title': data.title
        };
      }
    }
  };

  iu.init( 'upload_img_btn', function() {
    returnParam.imgOnSave.apply( this, arguments );
  } );

  return returnParam;
} );
